﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using System.Windows.Forms;

namespace TestDxfDocument
{
    class Templates
    {
        public static void Template(Dictionary<string, Object> data)//模板
        {
            DxfDocument dxf = new DxfDocument();

            #region 图层

            Layer contour = fun.SetLayer("contour");//轮廓层
            Layer dimensioning = fun.SetLayer("dimensioning");//尺寸层
            Layer refin = fun.SetLayer("refin");//基准线/内轮廓/虚线
            Layer center = fun.SetLayer("center");//中心线
            Layer textlayer = fun.SetLayer("textlayer");//文本层
            Layer hatching = fun.SetLayer("hatching");//填充层
            Layer additionalline = fun.SetLayer("additionalline");//附加线
            Layer cutting = fun.SetLayer("cutting");//切削层

            #endregion

            #region 参数

            string path = Convert.ToString(data["path"]);
            double offset = 10;

            #endregion

            #region 点

            Vector2 v1 = new Vector2(0, 0);
            Vector2 v2 = new Vector2(offset, 0);
            Vector2 v3 = new Vector2(offset, offset);
            Vector2 v4 = new Vector2(0, offset);

            #endregion

            #region 线

            LwPolyline lw1 = Pus.AddPointsToLwPolyLine(v1, v2, v3, v4, v1);
            Line line1 = new Line(v1, v3);

            #endregion

            #region 标注

            fun.DimensionLiner(dxf, dimensioning, v1, v2, offset, 180, "L=" + offset);

            #endregion

            #region 图框

            fun.DrawFrame(dxf, data, offset, Vector2.Zero);

            #endregion

            #region 编辑

            fun.AddEntities(dxf, contour, lw1, line1);

            #endregion

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);

        }
    }
}
